using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Emlyn.Website.Users;

public partial class AdminSubTitle : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        lblUserName.Text = Page.User.Identity.Name;

        User luser = (new UserQuery()).GetUserByUserName(Page.User.Identity.Name);

        if (
            (luser == null) ||
            (luser.AuthLevel < (GlobalAuthLevel)_authLevel) ||
            (!luser.Validated)
            )
        {
            Page.Response.Redirect("NotAuthorised.aspx");
        }
    }

    private int _authLevel = (int)GlobalAuthLevel.WebsiteAdmin;

    public string AuthLevel 
    {
        get
        {
            return _authLevel.ToString();
        }
        set
        {
            _authLevel = Int32.Parse(value);
        }
    }

    protected void lbLogout_Click(object sender, EventArgs e)
    {
        System.Web.Security.FormsAuthentication.SignOut();
        Response.Redirect("../default.aspx");
    }
}
